import { watcher } from 'feng3d';

/**
 * String 提示框
 */
export class TipString extends eui.Component implements eui.UIComponent
{
    public txtLab: eui.Label;

    value = '';

    constructor()
    {
        super();
        this.skinName = 'TipString';
        this.touchChildren = this.touchEnabled = false;
        //
        watcher.watch(this as TipString, 'value', this.valuechanged, this);
    }

    $onAddToStage(stage: egret.Stage, nestLevel: number)
    {
        super.$onAddToStage(stage, nestLevel);

        this.txtLab.text = this.value;
    }

    $onRemoveFromStage()
    {
        super.$onRemoveFromStage();
    }

    private valuechanged()
    {
        if (this.txtLab)
        {
            this.txtLab.text = String(this.value);
        }
    }
}

